import 'package:finance_app/src/entities/setting_data_entity.dart';
import 'package:finance_app/src/entities/contribution_entity.dart';
import 'package:finance_app/src/entities/country_entity.dart';
import 'package:finance_app/src/entities/depreciation_entity.dart';
import 'package:finance_app/src/entities/employment_type_entity.dart';
import 'package:finance_app/src/entities/grant_entity.dart';
import 'package:finance_app/src/entities/leave_type_entity.dart';
import 'package:finance_app/src/entities/martial_status_entity.dart';
import 'package:finance_app/src/entities/pass_type_entity.dart';
import 'package:finance_app/src/entities/salary_period_entity.dart';
import 'package:finance_app/src/entities/setting_alerts_entity.dart';
import 'package:finance_app/src/entities/setting_asset_category_entity.dart';
import 'package:finance_app/src/entities/setting_language_entity.dart';
import 'package:finance_app/src/entities/setting_template_entity.dart';
import 'package:finance_app/src/entities/setting_template_item_entity.dart';

settingDataEntityFromJson(SettingDataEntity data, Map<String, dynamic> json) {
	if (json['category_group'] != null) {
		data.categoryGroup = (json['category_group'] as List).map((v) => SettingDataCategoryGroup().fromJson(v)).toList();
	}
	if (json['category'] != null) {
		data.category = (json['category'] as List).map((v) => SettingDataCategory().fromJson(v)).toList();
	}
	if (json['tax'] != null) {
		data.tax = (json['tax'] as List).map((v) => SettingDataTax().fromJson(v)).toList();
	}
	if (json['currency'] != null) {
		data.currency = (json['currency'] as List).map((v) => SettingDataCurrency().fromJson(v)).toList();
	}
	if (json['common_currency'] != null) {
		data.commonCurrency = (json['common_currency'] as List).map((v) => SettingDataCurrency().fromJson(v)).toList();
	}
	if (json['payment_type'] != null) {
		data.paymentType = (json['payment_type'] as List).map((v) => SettingDataPaymentType().fromJson(v)).toList();
	}
	if (json['unit_type'] != null) {
		data.unitType = (json['unit_type'] as List).map((v) => SettingDataUnitType().fromJson(v)).toList();
	}
	if (json['paid_using'] != null) {
		data.paidUsing = (json['paid_using'] as List).map((v) => SettingDataPaidUsing().fromJson(v)).toList();
	}
	if (json['country'] != null) {
		data.country = (json['country'] as List).map((v) => CountryEntity().fromJson(v)).toList();
	}
	if (json['martial_status'] != null) {
		data.martialStatus = (json['martial_status'] as List).map((v) => MartialStatusEntity().fromJson(v)).toList();
	}
	if (json['pass_type'] != null) {
		data.passType = (json['pass_type'] as List).map((v) => PassTypeEntity().fromJson(v)).toList();
	}
	if (json['employment_type'] != null) {
		data.employmentType = (json['employment_type'] as List).map((v) => EmploymentTypeEntity().fromJson(v)).toList();
	}
	if (json['salary_period'] != null) {
		data.salaryPeriod = (json['salary_period'] as List).map((v) => SalaryPeriodEntity().fromJson(v)).toList();
	}
	if (json['leave_type'] != null) {
		data.leaveType = (json['leave_type'] as List).map((v) => LeaveTypeEntity().fromJson(v)).toList();
	}
	if (json['depreciation_type'] != null) {
		data.depreciationType = (json['depreciation_type'] as List).map((v) => DepreciationEntity().fromJson(v)).toList();
	}
	if (json['contribution'] != null) {
		data.contribution = (json['contribution'] as List).map((v) => ContributionEntity().fromJson(v)).toList();
	}
	if (json['asset_category'] != null) {
		data.assetCategory = (json['asset_category'] as List).map((v) => SettingAssetCategoryEntity().fromJson(v)).toList();
	}
	if (json['language'] != null) {
		data.language = (json['language'] as List).map((v) => SettingLanguageEntity().fromJson(v)).toList();
	}
	if (json['template'] != null) {
		data.template = (json['template'] as List).map((v) => SettingTemplateItemEntity().fromJson(v)).toList();
	}
	if (json['alerts'] != null) {
		data.alerts = (json['alerts'] as List).map((v) => SettingAlertsEntity().fromJson(v)).toList();
	}
	if (json['grants'] != null) {
		data.grants = (json['grants'] as List).map((v) => GrantEntity().fromJson(v)).toList();
	}
	return data;
}

Map<String, dynamic> settingDataEntityToJson(SettingDataEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['category_group'] =  entity.categoryGroup?.map((v) => v.toJson())?.toList();
	data['category'] =  entity.category?.map((v) => v.toJson())?.toList();
	data['tax'] =  entity.tax?.map((v) => v.toJson())?.toList();
	data['currency'] =  entity.currency?.map((v) => v.toJson())?.toList();
	data['common_currency'] =  entity.commonCurrency?.map((v) => v.toJson())?.toList();
	data['payment_type'] =  entity.paymentType?.map((v) => v.toJson())?.toList();
	data['unit_type'] =  entity.unitType?.map((v) => v.toJson())?.toList();
	data['paid_using'] =  entity.paidUsing?.map((v) => v.toJson())?.toList();
	data['country'] =  entity.country?.map((v) => v.toJson())?.toList();
	data['martial_status'] =  entity.martialStatus?.map((v) => v.toJson())?.toList();
	data['pass_type'] =  entity.passType?.map((v) => v.toJson())?.toList();
	data['employment_type'] =  entity.employmentType?.map((v) => v.toJson())?.toList();
	data['salary_period'] =  entity.salaryPeriod?.map((v) => v.toJson())?.toList();
	data['leave_type'] =  entity.leaveType?.map((v) => v.toJson())?.toList();
	data['depreciation_type'] =  entity.depreciationType?.map((v) => v.toJson())?.toList();
	data['contribution'] =  entity.contribution?.map((v) => v.toJson())?.toList();
	data['asset_category'] =  entity.assetCategory?.map((v) => v.toJson())?.toList();
	data['language'] =  entity.language?.map((v) => v.toJson())?.toList();
	data['template'] =  entity.template?.map((v) => v.toJson())?.toList();
	data['alerts'] =  entity.alerts?.map((v) => v.toJson())?.toList();
	data['grants'] =  entity.grants?.map((v) => v.toJson())?.toList();
	return data;
}

settingDataCategoryGroupFromJson(SettingDataCategoryGroup data, Map<String, dynamic> json) {
	if (json['data_type'] != null) {
		data.dataType = json['data_type'].toString();
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['key'] != null) {
		data.key = json['key'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	return data;
}

Map<String, dynamic> settingDataCategoryGroupToJson(SettingDataCategoryGroup entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['data_type'] = entity.dataType;
	data['id'] = entity.id;
	data['key'] = entity.key;
	data['name'] = entity.name;
	return data;
}

settingDataCategoryFromJson(SettingDataCategory data, Map<String, dynamic> json) {
	if (json['data_type'] != null) {
		data.dataType = json['data_type'].toString();
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['key'] != null) {
		data.key = json['key'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['type'] != null) {
		data.type = json['type'].toString();
	}
	if (json['category_group'] != null) {
		data.categoryGroup = json['category_group'].toString();
	}
	if (json['is_recommended'] != null) {
		data.isRecommended = json['is_recommended'] is String
				? int.tryParse(json['is_recommended'])
				: json['is_recommended'].toInt();
	}
	return data;
}

Map<String, dynamic> settingDataCategoryToJson(SettingDataCategory entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['data_type'] = entity.dataType;
	data['id'] = entity.id;
	data['key'] = entity.key;
	data['name'] = entity.name;
	data['type'] = entity.type;
	data['category_group'] = entity.categoryGroup;
	data['is_recommended'] = entity.isRecommended;
	return data;
}

settingDataTaxFromJson(SettingDataTax data, Map<String, dynamic> json) {
	if (json['data_type'] != null) {
		data.dataType = json['data_type'].toString();
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['key'] != null) {
		data.key = json['key'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['rate'] != null) {
		data.rate = json['rate'] is String
				? int.tryParse(json['rate'])
				: json['rate'].toInt();
	}
	if (json['enabled'] != null) {
		data.enabled = json['enabled'] is String
				? int.tryParse(json['enabled'])
				: json['enabled'].toInt();
	}
	return data;
}

Map<String, dynamic> settingDataTaxToJson(SettingDataTax entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['data_type'] = entity.dataType;
	data['id'] = entity.id;
	data['key'] = entity.key;
	data['name'] = entity.name;
	data['rate'] = entity.rate;
	data['enabled'] = entity.enabled;
	return data;
}

settingDataCurrencyFromJson(SettingDataCurrency data, Map<String, dynamic> json) {
	if (json['data_type'] != null) {
		data.dataType = json['data_type'].toString();
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['key'] != null) {
		data.key = json['key'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	return data;
}

Map<String, dynamic> settingDataCurrencyToJson(SettingDataCurrency entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['data_type'] = entity.dataType;
	data['id'] = entity.id;
	data['key'] = entity.key;
	data['name'] = entity.name;
	return data;
}

settingDataPaymentTypeFromJson(SettingDataPaymentType data, Map<String, dynamic> json) {
	if (json['data_type'] != null) {
		data.dataType = json['data_type'].toString();
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['key'] != null) {
		data.key = json['key'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	return data;
}

Map<String, dynamic> settingDataPaymentTypeToJson(SettingDataPaymentType entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['data_type'] = entity.dataType;
	data['id'] = entity.id;
	data['key'] = entity.key;
	data['name'] = entity.name;
	return data;
}

settingDataUnitTypeFromJson(SettingDataUnitType data, Map<String, dynamic> json) {
	if (json['data_type'] != null) {
		data.dataType = json['data_type'].toString();
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['key'] != null) {
		data.key = json['key'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['is_editable'] != null) {
		data.isEditable = json['is_editable'] is String
				? int.tryParse(json['is_editable'])
				: json['is_editable'].toInt();
	}
	return data;
}

Map<String, dynamic> settingDataUnitTypeToJson(SettingDataUnitType entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['data_type'] = entity.dataType;
	data['id'] = entity.id;
	data['key'] = entity.key;
	data['name'] = entity.name;
	data['is_editable'] = entity.isEditable;
	return data;
}

settingDataPaidUsingFromJson(SettingDataPaidUsing data, Map<String, dynamic> json) {
	if (json['data_type'] != null) {
		data.dataType = json['data_type'].toString();
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['key'] != null) {
		data.key = json['key'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	return data;
}

Map<String, dynamic> settingDataPaidUsingToJson(SettingDataPaidUsing entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['data_type'] = entity.dataType;
	data['id'] = entity.id;
	data['key'] = entity.key;
	data['name'] = entity.name;
	return data;
}